package com.ficus.road.maintain.core.model.zh.roadgps;

import com.ficus.road.maintain.core.model.RoadInfo;
import com.ficus.road.maintain.core.model.RoadTypeEnum;
import lombok.Data;

/**
 * @author xiawen yang
 * @date 2022/3/30 下午3:19
 */
@Data
public class BasicRoadZH {
    private String roadid;

    private String roadname;

    private String roadrangedesc;

    private String roadtype;
    // 街镇名称
    private String town;
    // 街镇编码
    private String towncode;
    // 标段id
    private String projectid;
    //
    private String unitid;
    // 养护单位id
    private String unitidcode;
    // 道路所属分中心编码
    private String departid;

    private String startlocation;

    private String endlocation;

    private String length;

    private String area;

    private String locationdesc;

    public RoadInfo convert2RoadInfo(BasicRoadZH zh) {
        return RoadInfo.builder()
                .id(zh.getProjectid() + zh.getRoadid())
                .secNum(zh.getRoadid())
                .districtId(zh.getTowncode())
                .town(zh.getTown())
                .unitId(zh.getProjectid())
                .companyId(zh.getUnitidcode())
                .roadName(zh.getRoadname())
                .secLen(zh.getLength())
                .startStake(zh.getStartlocation())
                .endStake(zh.getEndlocation())
                .companyName(zh.getUnitid())
                .secArea(zh.getArea())
                .roadType(getRoadType(zh.getRoadtype()))
                .build();
    }

    public RoadTypeEnum getRoadType(String roadType) {
        RoadTypeEnum res = null;
        switch (roadType) {
            case "城市道路":
                res = RoadTypeEnum.HIGHWAY;
                break;
            case "直管公路":
                res = RoadTypeEnum.DIRECT;
                break;
            case "农村公路":
                res = RoadTypeEnum.ROAD;
                break;
        }
        return res;
    }
}
